package com.zhang.dao.impl;

import com.zhang.dao.LoveDao;
import com.zhang.domain.Love;
import com.zhang.utils.JdbcUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class LoveDaoImpl implements LoveDao {

    private JdbcTemplate template = new JdbcTemplate(JdbcUtils.getDataSource());

    @Override
    public List<Love> selectLove(int userId) {
        String sql = "SELECT * FROM `love`l,`user_love` ul WHERE  ul.loveId=l.`id` AND ul.userId =?";
        return template.query(sql,new BeanPropertyRowMapper<Love>(Love.class),userId);
    }
}
